# -*- coding: utf-8 -*-
import unittest
from selenium import webdriver
import time
import xlrd
from Page.loginPage import loginPage
from publicModule.login import login
from Page.sessionPage import sessionPage
from publicModule.session import session
from Page.noscanningPage import noscanningPage
class Test_Session(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        print('开始测试')
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        self.driver.get("http://10.22.26.34:8080/fwd/indexlis.jsp")
        time.sleep(2)
        self.loginPage = loginPage(self.driver)
        self.login = login(self.driver)
        self.sessionPage=sessionPage(self.driver)
        self.session=session(self.driver)
        self.noscanningPage=noscanningPage(self.driver)
    @classmethod
    def tearDownClass(self):
        print('结束测试')
        self.driver.quit()
    def test01(self):
        filename = '..//TestData//loginData.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            username = row_content[0]
            password = row_content[1]
            orgcode = row_content[2]
            login.login(self, username, password, orgcode)
    def test02(self):
        session.grouplife(self)
        time.sleep(1)
        session.acceptpayment(self)
        time.sleep(1)
    def test03(self):
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            RecAccountNum = row_content[24]
            session.payManagement(self,RecAccountNum)
            time.sleep(1)
    def test04(self):
        filename = '..//TestData//payment.xls'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            AgentName = row_content[11]
            GrpName = row_content[5]
            Money = int(row_content[2])
            ConfirmDesc = row_content[12]
            BUssGrid1 = row_content[13]
            BUssGrid2 = row_content[14]
            BUssGrid3 = int(row_content[2])
            session.paymentifm(self,AgentName,GrpName,Money,ConfirmDesc,BUssGrid1,BUssGrid2,BUssGrid3)
if __name__ =='__main__':
    # unittest.main()
    suite = unittest.TestLoader.loadTestsFromTestCase(Test_Session)
    unittest.TextTestRunner().run(suite)







